import 'package:flutter/material.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';

class PlayVideo extends StatefulWidget {
  const PlayVideo({super.key, required this.url});

  final String url;

  @override
  State<PlayVideo> createState() => _PlayVideoState();
}

class _PlayVideoState extends State<PlayVideo> {
  // Create a [Player] to control playback.
  late final player = Player();

  // Create a [VideoController] to handle video output from [Player].
  late final playController = VideoController(player);

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    player.open(Media(widget.url));
  }

  @override
  void dispose() {
    // TODO: implement dispose
    player.dispose();
    super.dispose();
  }



  @override
  Widget build(BuildContext context) {
    return Video(controller: playController);
  }
}
